What is Razor view engine in asp.net MVC?
What is Razor view engine in asp.net MVC?
The information provided here is part of Export Import Training online After the exploration of information technology, the world is on our finger tips to get any piece of information. However when I went through different subjects on the web, I realized, like every thing in society, internet also carries the good and the bad. I was surprised to note that, I could not find any good quality free tutorial program to enter in a good business especially in
Steilla Mitchel
11-Mar-2022Razor View Engine :
In asp.net mvc, Razor view engine is syntax that allow us to write server side code in view page. It help to combine the server side with HTML in a fluid manner. If you know c#, vb.net and bit HTML language then you can easily use razor in html file because Razor supports C# and visual basic programming language.
Syntax :
In Razor view engine, Razor code is enclosed within @{....}. Here @ character sign is tell the beginning of Razor code. This code can be a single line or a block of statements. Razor view engine syntax is as like below,
In the above syntax '@{' is used to beginning of Razor code and '}' is used to end of the code.
Types of Block Statement in Razor :
In Razor, we have generally two type of block statement that we used that is as follow,
1- Single statement block and Inline expression:
As we know that the Razor code is write within @{...}, then the following code is represents the single statement block,
2- Multiple statement block and Inline expression:
In multiple statement block, all Razor variables are defines in a single @{...} and we need to end all variable line with semicolon( ; ). Multiple statement code block is shown as like,
Generally, In view page Razor engine code write at the top portion so that Razor code is accessible everywhere in that page. If we declare a Razor variable in middle of view page and access it at top position then it thrown error as like bellow code,